<template>
	<view class="result">
		<view
			class="custom-navbar"
			:style="{
				height: paddingHeight + 'px',
				paddingTop: globalData.paddingTop + 'px'
			}"
		>
			<view
				class="bakc_icon"
				:style="{ height: globalData.lineHeight + 'px' }"
			>
				<uni-icons
					color="#000000"
					type="back"
					@click="next"
					size="20"
				/>
			</view>
			<view
				class="navbar-name"
				:style="{
					lineHeight: globalData.lineHeight + 'px',
					height: globalData.lineHeight + 'px'
				}"
			></view>
		</view>
		<view class="r-container" :style="{ paddingTop: paddingHeight + 'px' }">
			<view class="leve-box">
				<view class="title">
					<text style="margin-right: 10rpx">代谢等级</text>
					<u-icon
						@click="modalsShow = true"
						name="http://oss.antaimedical.com/images/pro/2025/03/67c8131de4b0be9d44423456soSXafViCpJ93af36470205df9e9b3ebe96ce310ced9.png"
						size="15"
					></u-icon>
				</view>
				<view class="img">
					<image :src="levelSrc" />
				</view>
				<view class="leve-section">
					<view class="text">脂肪</view>
					<view class="text2">{{ leveArticle.title }}</view>
					<view class="text">碳水</view>
				</view>
			</view>
			<view class="ZF-box">
				<view class="l item">
					<view class="text">脂肪供能占比</view>
					<view class="text2">{{ info.choRate || '--'}}%</view>
				</view>
				<view class="r item">
					<view class="text">理想等级区间</view>
					<view class="text2"
						>{{ explainData.idealRerFloor|| '--' }}-{{
							explainData.idealRerUpper|| '--'
						}}</view
					>
				</view>
			</view>
			<view class="tips">
				<!-- <u-parse
					:content="leveArticle.content"
					:tagStyle="style"
				></u-parse> -->

				代谢状态：{{ explainData.gradeExplain || '--'}}
				<br />
				建议：{{ explainData.suggest || '--'}}
				<br />
				提示：{{ explainData.consequence || '--'}}
			</view>
			<view class="swiper">
				<u-swiper
					:list="swiperList"
					imgMode="widthFix"
					bgColor="transparent"
					circular
					@click="clickSwiper"
					@change="(e) => (current = e.current)"
				>
				</u-swiper>
			</view>
		</view>
		<view class="next_button" @click="next">完成</view>
		<u-modal
			:show="modalsShow"
			title="提示"
			confirmText="确定"
			confirmColor="#1F2434"
			@confirm="modalsShow = false"
		>
			<view slot="default" class="modal-content">
				<view class="text">一级：0~20%代谢底物为碳水，其余为脂肪</view>
				<view class="text">二级：20~40%代谢底物为碳水，其余为脂肪</view>
				<view class="text">三级：40~60%代谢底物为碳水，其余为脂肪</view>
				<view class="text">四级：60~80%代谢底物为碳水，其余为脂肪</view>
				<view class="text"
					>五级：80~100%代谢底物为碳水，其余为脂肪</view
				>
			</view>
		</u-modal>
	</view>
</template>

<script>
import { mapGetters } from 'vuex'
import {
	findMeasureArticle,
	getIsOpenActivity,
	findMeasureResult,
    findMetabolismGradeExplain
} from '@/api/index.js'
let app = getApp()
export default {
	data() {
		return {
			paddingHeight: uni.getStorageSync('navbarHeight'),
			globalData: app.globalData,
			imgUrl: this.$imgUrl,
			info: {},
			levelSrc: '',
			current: 0, //轮播图索引
			modalsShow: false,
			swiperList: [
				'http://oss.antaimedical.com/images/pro/2025/03/67c81deee4b0d615350f314ehagP7pF00ClJaa5ef18939f2a83e4b88e22e3464b6f8.png',
				'http://oss.antaimedical.com/images/pro/2025/03/67c81dffe4b0be9d44423457dNKDRVppjhbxa9ad40356601429e81bf3e7a309366be.png'
			],
			leveObj: {
				1: '高燃脂状态',
				2: '燃脂状态',
				3: '中度燃脂状态',
				4: '低燃脂状态',
				5: '非燃脂状态'
			},
			leveColorObj: {
				1: '#7cd37e',
				2: '#78b2dd',
				3: '#9c70de',
				4: '#ffa168',
				5: '#f1c56b'
			},
			leveArticle: {},
			idealData: {
				idealFloor: '',
				idealUpper: ''
			},
			style: {
				h1: 'text-align:left;color:#333;margin-bottom:32rpx;',
				h2: 'text-align:left;color:#333;margin-bottom:32rpx;',
				h3: 'text-align:left;color:#333;margin-bottom:32rpx;',
				h4: 'text-align:left;color:#333;margin-bottom:32rpx;',
				h5: 'text-align:left;color:#333;margin-bottom:32rpx;',
				p: 'text-align:left;',
				text: 'text-align:left;',
				view: 'text-align:left;',
				ul: 'text-align:left;padding:0',
				li: 'text-align:left;'
			},
            explainData:{}
		}
	},
	computed: {
		...mapGetters({
			userInfo: 'getUserInfo'
		})
	},
	onLoad(OPTIONS) {
		this.info = JSON.parse(OPTIONS.data)
		this.info.choRate = (this.info.choRate * 100).toFixed() || '--'
		// this.info.rerLevel = 1
		// this.info.tag = 2
		if (this.info.rerLevel == 1) {
			this.levelSrc =
				'http://oss.antaimedical.com/images/pro/2025/03/67c90661e4b0be9d44423458PqUdtqVNSks2ca74d18a93b5130849faa8d17474f291.png'
		} else if (this.info.rerLevel == 2) {
			this.levelSrc =
				'http://oss.antaimedical.com/images/pro/2025/03/67c90674e4b0d615350f314fAOAyK8ThVI8K86e7da21274d78e7e27fee80919b2630.png'
		} else if (this.info.rerLevel == 3) {
			this.levelSrc =
				'http://oss.antaimedical.com/images/pro/2025/03/67c8133ee4b0d615350f314dbKsgYiG2A9bLd3d2c4de898de7fcce3f1955674bfbaf.png'
		} else if (this.info.rerLevel == 4) {
			this.levelSrc =
				'http://oss.antaimedical.com/images/pro/2025/03/67c90685e4b0d615350f3150i5cgYSAjTO1R26663d0ce60459d87df83b14ae7b9046.png'
		} else if (this.info.rerLevel == 5) {
			this.levelSrc =
				'http://oss.antaimedical.com/images/pro/2025/03/67c90698e4b0be9d44423459j5j69Ooczx9e05bae7bc046d0b190f81588ac4035d4f.png'
		}
		this.findMeasureArticle()
	},
	methods: {
		clickSwiper(val) {
			if (val == 1) {
				uni.switchTab({
					url: '/pages/explore/index'
				})
			} else {
				this.handleTo28Day()
			}
		},

		handleTo28Day() {
			getIsOpenActivity({ userId: this.userInfo.userId }).then((res) => {
				if (res.data == 1) {
					uni.navigateTo({
						url: '/pagesB/clockInDay/index'
					})
				} else {
					uni.navigateTo({
						url: '/pagesB/clockInDay/notActivity'
					})
				}
			})
		},

		next() {
			uni.switchTab({
				url: '/pages/health/index'
			})
		},
		findMeasureArticle() {
			let params = {
				rerLevel: this.info.rerLevel,
				tag: this.info.tag,
				label: this.info.label
			}
			findMeasureArticle(params).then((res) => {
				this.leveArticle = res.data
			})
			findMeasureResult(params).then((res) => {
                this.explainData = res.data
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.result {
	display: flex;
	align-items: center;
	flex-direction: column;
	.r-container {
		width: 100%;
		// height: 910rpx;
		padding: 0 26rpx 0;
		display: flex;
		align-items: center;
		flex-direction: column;
		background: url('http://oss.antaimedical.com/images/pro/2025/03/67c90cfbe4b0d615350f3151VECvFbFMMbRb09ee73d79638a0d3c95a6335b6bc49db.png')
			no-repeat;
		background-size: 100% 548rpx;
		padding-bottom: 150rpx;
		.leve-box {
			margin-top: 30rpx;
			width: 100%;
			padding: 24rpx 26rpx;
			background: #ffffff;
			border-radius: 15rpx;
			.title {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #1f2333;
				text-align: left;
				display: flex;
				align-items: center;
				margin-bottom: 14rpx;
			}
			.img {
				width: 100%;
				height: 332rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
		}
		.leve-section {
			display: flex;
			justify-content: space-around;
			align-items: center;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			line-height: 48rpx;
			.text {
				color: rgba(31, 36, 52, 0.5);
			}
			.text2 {
				color: rgba(31, 36, 52, 0.8);
			}
		}
		.ZF-box {
			padding: 24rpx 38rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 100%;
			border-bottom: 2rpx dashed #f4f4f4;
			.item {
				width: 290rpx;
				height: 116rpx;
				border-radius: 12rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				padding: 0 24rpx;
				.text {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #5a667e;
					text-align: left;
				}
				.text2 {
					font-weight: 500;
					font-size: 32rpx;
					color: #1f2434;
					text-align: left;
				}
			}
			.l {
				background-color: #fef9ef;
			}
			.r {
				background-color: #edfbf9;
			}
		}
		.tips {
			padding: 26rpx;
			width: 100%;
			border-radius: 15rpx;
			background-color: #f3f4f7;
			margin-top: 38rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: rgba(31, 36, 52, 0.8);
			text-align: left;
			line-height: 48rpx;
		}
		.swiper {
			width: 100%;
			height: 168rpx;
			margin-top: 38rpx;
			margin-bottom: 64rpx;
			// .indicator {
			// 	display: flex;
			// 	justify-content: center;

			// 	&__dot {
			// 		height: 12rpx;
			// 		width: 120rpx;
			// 		border-radius: 4rpx;
			// 		background-color: #e4e5fc;
			// 		margin: 0 5px;
			// 		transition: background-color 0.3s;

			// 		&--active {
			// 			background-color: #d2d4f8;
			// 		}
			// 	}
			// }
		}
	}

	.next_button {
		position: fixed;
		bottom: 76rpx;
		left: 50%;
		transform: translateX(-50%);
		width: 423rpx;
		height: 85rpx;
		background: #1f2434;
		border-radius: 48rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #ffffff;
		text-align: center;
	}

	.modal-content {
		font-size: 26rpx;
		color: #afafaf;
		.text {
			text-align: left;
			margin-top: 10rpx;
		}
	}
}
/deep/.u-popup__content {
	border-radius: 20rpx !important;
	.u-modal {
		.u-modal__title {
			padding-top: 32rpx !important;
			font-weight: 500 !important;
		}
		.u-modal__button-group__wrapper {
			height: 84rpx !important;
		}
		.u-modal__button-group__wrapper__text {
			font-weight: 500;
		}
	}
}
.popup-content {
	padding: 32rpx;
	min-height: 720rpx;

	.title {
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: #000000;
	}

	.con-box {
		padding: 32rpx 48rpx;
		background: #f2f3fd;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		margin-top: 48rpx;
		min-height: 400rpx;
		.item {
			display: flex;
			justify-content: space-between;
			align-items: flex-start;
			margin-bottom: 28rpx;

			&:last-child {
				margin-bottom: 0;
			}

			.text {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #666666;
				text-align: left;
			}

			.num {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
			}
		}
	}

	.btn {
		width: 100%;
		height: 88rpx;
		background: #545dde;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: #ffffff;
	}
}
</style>
